package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.bean.PanghuShopGoods;
import com.hualan.dao.ShopGoodsList;
import com.hualan.dao.impl.ShopGoodsListImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/shopServlet")
public class ShopGoodsListServlet extends HttpServlet {
    private static ShopGoodsList shopGoodsList = new ShopGoodsListImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        int page = Integer.parseInt(req.getParameter("page"));
        int size = Integer.parseInt(req.getParameter("size"));
        List<PanghuShopGoods> list = shopGoodsList.selectShopGoodsAll(page,size);
        resp.getWriter().write(JSON.toJSONString(list));
    }
}
